<div id="main_content" style="float: left; background: #fff;">
    <h3><?php echo $title; ?></h3>
    <div class="form_search wrapFrmEmploryeSearch" style="width:340px;">
        <form action="" method="POST" name="frmEmploryeSearch" class="frmEmploryeSearch">
        <table width="100%">
            <tr>
                <td><?php echo $this->lang->line('OVT_Name'); ?></td>
                <td><input type="text" name="txtKeyword" maxlength="255" value="<?php if(isset($txtKeyword)){echo $txtKeyword;} ?>" ></td>
                <td>
                    <input type="submit" name="btnSubmit" value="<?php echo $this->lang->line('OVT_Search');?>">
                </td>
            </tr>
        </table>
        </form>
    </div>
    <a class="new_regis" href="javascript:void(0);"><?php echo $this->lang->line('OVT_Newregister');?></a>
    <div class="table_list leaveregistration">
        <table width="100%" class="list_view_data" border="0" cellspacing="0" cellpadding="0">
            <tr align="center">
                <th><?php echo $this->lang->line('OVT_Order'); ?></th>
                <th><?php echo $this->lang->line('OVT_Fullname'); ?></th>
                <th><?php echo $this->lang->line('LR_StartDate'); ?></th>
                <th><?php echo $this->lang->line('LR_EndDate'); ?></th>
                <th><?php echo $this->lang->line('LR_StartTime'); ?></th>
                <th><?php echo $this->lang->line('LR_EndTime'); ?></th>
                <th><?php echo $this->lang->line('OVT_ReasonOfOvertime'); ?></th>
                <th><?php echo $this->lang->line('LR_Action'); ?></th>
                <th width="10%"><?php echo $this->lang->line('spl__Delete'); ?></th>
            </tr>
            <?php
                if (count($data)){
                foreach ($data as $row){
                    $path=($row['Del_Flag']==0) ? base_url()."public/sites/images/check-icon.png" : base_url()."public/sites/images/uncheck.gif";
            ?>
                <tr id="<?php echo $row['OvertimeRegistrationId'];?>">
                    <td><?php echo ++ $order; ?></td>
                    <td class="table_col">
                        <a class="post_edit" href ="javascript:void(0);" rel="<?php echo $row['OvertimeRegistrationId'];?>" rel1="<?php echo $row['EmployeeId'];?>" >
                            <?php echo dQuotes(subString($row['EmployeeName']));?>
                        </a>
                    </td>
                    <td class="table_col"><?php echo date('Y/m/d',strtotime($row['StartDate'])); ?></td>
                    <td class="table_col"><?php echo date('Y/m/d',strtotime($row['EndDate'])); ?></td>
                    <td class="table_col"><?php echo date('G:i',strtotime($row['StartTime'])); ?></td>
                    <td class="table_col"><?php echo date('G:i',strtotime ($row['EndTime'])); ?></td>
                    <td class="table_col" ><?php echo dQuotes($row['ReasonOfOvertime']); ?></td>
                    <td align="center">
                        <a class="post_edit" href ="javascript:void(0);" rel="<?php echo $row['OvertimeRegistrationId'];?>" rel1="<?php echo $row['EmployeeId'];?>" >
                            <img src="<?php echo base_url() ?>public/sites/images/Pencil.png" width="15"/>
                        </a>
                        <a class="post_add" href ="javascript:void(0);" rel="<?php echo $row['EmployeeId'];?>" >
                            <img src="<?php echo base_url() ?>public/sites/images/add.png" width="15" />
                        </a>
                    </td>
                    <td align="center"><img src="<?php echo $path;?>"/></td>
                </tr>
            <?php 
                }
            ?>              
        </table>
        <?php
        }
        else{
        ?>
             </table>
            <p><?php echo $this->lang->line('LR_null'); ?></p>
         <?php
        }
        ?>
    </div>
    <div class="h_pagination">
        <?php echo $pagi;  ?>
    </div>    
</div>
<form id="frmSubmit" action="<?php echo base_url();?>overtime/edit" Method="POST">
  <input type="hidden" id="hidOvertimeId" name="hidOvertimeId">
  <input type="hidden" id="hidEmployeeId" name="hidEmployeeId">
  <input type="hidden" name="hidDel" value="true">
</form>
<form id="frmSubmitAdd" action="<?php echo base_url();?>overtime/add" Method="POST">
  <input type="hidden" id="hidAddEmployeeId" name="hidAddEmployeeId">
  <input type="hidden" name="hidDel" value="true">
</form>
<script>
    $( ".new_regis" ).click(function() {
         $( "#frmSubmitAdd" ).submit();
    });    
    $( ".post_add" ).click(function() {     
         $('#hidAddEmployeeId').val($(this).attr('rel'));
         $( "#frmSubmitAdd" ).submit();
    });
    $( ".post_edit" ).click(function() {     
         $('#hidOvertimeId').val($(this).attr('rel'));
         $('#hidEmployeeId').val($(this).attr('rel1'));
         $( "#frmSubmit" ).submit();
    });     
    // pagination 
    $(document).ready(function() {
        $('.h_pagination a').click(function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            if (url != 'javascript:void(0)') {
                $('.frmEmploryeSearch').attr('action', url);
                $('.frmEmploryeSearch').submit();
            }
        });
        $('.btnSubmit').click(function(e) {
            e.preventDefault();
            $('.frmEmploryeSearch').attr('action', '/overtime');
            $('.frmEmploryeSearch').submit();
        });
    });      
    function deleteLeaveRegistration(id){
        $("#dialog").dialog({
            open: function( event, ui ) {
                $(this).html('<?php echo $this->lang->line('OVT_titledel'); ?>');
            },
            buttons: [
                { 
                    text: "<?php echo $this->lang->line('OVT_ok');?>", 
                    click: function() { 
                        $.ajax({
                            type: "POST",
                            url: "<?php echo base_url()."overtime/del" ?>",
                            data: {id:id}
                        }).done(function(msg) {
                            if(msg=="ok"){
                                $("tr#"+id).remove();
                                window.location.href='<?php echo base_url()."overtime" ?>';
                            }
                            else{
                                $( this ).dialog( "close" ); 
                            }
                        });
                        $( this ).dialog( "close" ); 
                    }
                },
                {
                    text: "<?php echo $this->lang->line('OVT_cancel');?>",
                    click:function(){$( this ).dialog( "close" );}            
                }
          ]
        });        
    }
</script>